package com.laundry.controller;

import com.laundry.dto.ResultDTO;
import com.laundry.entity.Order;
import com.laundry.service.OrderService;
import com.laundry.vo.OrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("rootPackageOrderController")
@RequestMapping("/admin/orders/v1")
public class AdminOrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("/list")
    public ResultDTO getOrderList() {
        try {
            List<Order> orders = orderService.getAllOrders();
            List<OrderVO> orderVOs = orderService.convertToOrderVOList(orders);
            return ResultDTO.success(orderVOs);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultDTO.error("获取订单列表失败：" + e.getMessage());
        }
    }
} 